#include "QueryTree2.h"
#include "QueryTreeTuple.h"
#include <vector>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

Symbol::Symbol(){
	count = 0;
}

Symbol::~Symbol(){
}

symbolIndex Symbol::insertSymbol(SymbolTuple* tuple) {
	symbolIndex index = count;
	symbolTable.push_back(*tuple);
	count++;
	return index;
}

design_entity Symbol::getSymbolType(symbolIndex index){
	return symbolTable[index].getType();
}

string Symbol::getSymbolName(symbolIndex index) {
	return symbolTable[index].getName();
}

symbolIndex Symbol::searchSymbolName(string name){
	for(int i = 0;i < count; i ++) {
		if(symbolTable[i].getName() == name)
			return i;
	}
	return -1;
}

vector<symbolIndex> Symbol::searchSymbolType(design_entity type) {
	vector<symbolIndex> result;
	for(int i = 0;i <count; i++) {
		if(symbolTable[i].getType() == type)
			result.push_back(i);
	}
	return result;
}

int Symbol::getSize() {
	return count;
}

SymbolTuple Symbol::getSymbolTupleAt(symbolIndex index) {
	return symbolTable[index];
}

Result::Result() {
	booleanResult = false;
	count = 0;
}

Result::~Result() {
}

void Result::insertResult(ResultClauseTuple* tuple) {
	if(booleanResult)
		cout<<"error"<<endl;
	else {
		resultList.push_back(*tuple);
		count++;
	}
}

void Result::insertBooleanResult() {
	booleanResult = true;
}

bool Result::isBooleanResult() {
	return booleanResult;
}

vector<ResultClauseTuple> Result:: getAllResult() {
	return resultList;
	
}

int Result::getSize() {
	return count;
}

ResultClauseTuple Result:: getResultClauseTupleAt(int index) {
	return resultList[index];
}

Relation::Relation(){
	count = 0;
}

Relation::~Relation(){

}

void Relation::insertRelation(RelationTuple* tuple) {
	relationList.push_back(*tuple);
	count++;
}

vector<RelationTuple> Relation::getAllRelation() {
	return relationList;
}

int Relation::getSize(){
	return count;
}

RelationTuple Relation:: getRelationTupleAt(int index) {
	return relationList[index];
}

WithClause::WithClause(){
	count = 0;
}

WithClause::~WithClause(){

}

void WithClause::insertWithClause(WithClauseTuple* tuple) {
	withList.push_back(*tuple);
	count++;
}

vector<WithClauseTuple> WithClause::getAllWith() {
	return withList;
}

int WithClause::getSize() {
	return count;
}

WithClauseTuple WithClause::getWithClauseTupleAt(int index) {
	return withList[index];
}

Pattern::Pattern(){

}

Pattern::~Pattern(){

}



